package com.all.play.myadaptertoadapter.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.all.play.myadaptertoadapter.R;
import com.all.play.myadaptertoadapter.bean.MyBean;

import java.util.List;

/**
 * Created by 聪明一只哈 on 2018/5/18.
 * Time: 2018/5/18  9:11
 */

public class MyItemTwoAdapter extends RecyclerView.Adapter<MyItemTwoAdapter.MyItemoneOneVh> {


    private Context context;
    private List<MyBean.ResultBean.BannerInfoBean> banner_info;

    public MyItemTwoAdapter(Context context, List<MyBean.ResultBean.BannerInfoBean> banner_info) {

        this.context = context;
        this.banner_info = banner_info;
    }

    @Override
    public MyItemoneOneVh onCreateViewHolder(ViewGroup parent, int viewType) {

        return new MyItemoneOneVh(View.inflate(context, R.layout.item_two_two,null));
    }

    @Override
    public void onBindViewHolder(MyItemoneOneVh holder, int position) {

        MyBean.ResultBean.BannerInfoBean infoBean = banner_info.get(position);
        holder.tv_two_a.setText(infoBean.getImage());
        holder.tv_two_b.setText(infoBean.getOption()+"");
        holder.tv_two_c.setText(infoBean.getType()+"");


    }

    @Override
    public int getItemCount() {
        return banner_info==null?0:banner_info.size();
    }


    class MyItemoneOneVh extends RecyclerView.ViewHolder{
        TextView tv_two_a;
        TextView tv_two_b;
        TextView tv_two_c;
        public MyItemoneOneVh(View itemView) {
            super(itemView);
            tv_two_a=itemView.findViewById(R.id.tv_two_a);
            tv_two_b=itemView.findViewById(R.id.tv_two_b);
            tv_two_c=itemView.findViewById(R.id.tv_two_c);

            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(context, "这是第二个条目,传值方式与第一个条目方式一致", Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
}
